function projectionArea(grid) {
    let xy = 0, xz = 0, yz = 0
    let empty = 0;
    let yzArray = [];

    grid.forEach((value, index) => {
        xy += value.length;
        xz += Math.max(...value);
        value.forEach((yzValue, index) => {
            if (!yzValue) {
                empty++;
            }
            let yzNumber = yzArray[index] ? yzArray[index] : 0;

            if (yzValue > yzNumber) {
                yzArray[index] = yzValue;
            }
        });
    });

    return xy + xz + yzArray.reduce((sum, value) => sum + value) - empty;
}

console.log(
    "17: ",
    projectionArea([
        [1, 2],
        [3, 4],
    ])
);
